package com.asiainfo.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.asiainfo.bean.RoleBean;
import com.asiainfo.common.mapper.BaseMapper;
import com.asiainfo.common.service.BaseService;
import com.asiainfo.dao.RoleMapper;
import com.asiainfo.service.RoleService;

/**
 * 用户服务实现
 * 
 * @author luhf
 * @date Jan 7, 2013 1:21:27 PM
 */
@Service("impl.roleServiceImpl")
public class RoleServiceImpl extends BaseService<RoleBean> implements RoleService{

	@SuppressWarnings("rawtypes")
	private BaseMapper mapper;

	@Autowired
	@Qualifier("mapper.roleMapper")
	private RoleMapper roleMapper;

	public Map<String,Object> getRoleList(int rows,int page){
		return getListByPage(rows,page);
	}

	public Map<String,Object> addRole(RoleBean roleBean){
		Map<String,Object> map=new HashMap<String,Object>(1);
		try{
			roleMapper.insertRole(roleBean);
			map.put("success","true");
		}catch(Exception e){
			e.printStackTrace();
		}
		return map;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public BaseMapper getMapper(){
		if(mapper==null)
			mapper=roleMapper;//默认mapper
		return mapper;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public void setMapper(BaseMapper mapper){
		this.mapper=mapper;
	}
}
